#ifndef CAMERA_HEADER
#define CAMERA_HEADER

#include "OblivionPhysics.h"

#include "glm/glm.hpp"
#include "glm/ext.hpp"

enum CAMERA_GET_ENUM
{
	MODELVIEW_MATRIX = 0,
	PROJECTION_MATRIX
};

class Camera
{    
public:

    Camera(const glm::vec2 & center, 
		float spanW, 
		float spanH,
		float pixToMeterRatio);

	//OpenGL fixed function

	void SetPerspectiveMatrix( 
		float left,
		float right,
		float bottom,
		float top);

	float * GetFloat (CAMERA_GET_ENUM flag);
	
	void SetPixelToMeterRatio( float Rat );
	
	void IncrementPixelToMeterRatio( float inc);

	void SetModelviewMatrix();
	
	void SetModelviewMatrix(float scale);

	void SetFollow(PhysicsPrimitive * inPrim);

	void SetDoFollow(bool enableFollow);

	bool IsFollowing();
	
	void GetMinMax( glm::vec2 & oMin, glm::vec2 & oMax);
	
	//Moves camera to a world position
	void MoveTo( const glm::vec2 & worldPos );
	
	//Moves the camera by incrementing its current position.
	void MoveByDelta( const glm::vec2 & amt );

	glm::mat4x4 * GetGLMMat(CAMERA_GET_ENUM flag);

	void Update();

private:
	//Perspective matrix
	glm::mat4x4 mPMat;

	//Modelview matrix
	glm::mat4x4 mMVMat;

	//
	//Used to calculate the modelview matrix
	//Scale factor
	float mPixelPerMeter;

	//Model matrix
	glm::mat4x4 mModel;

	glm::vec2 mCenter;
	float mWh[2];

	//A physics primitive to follow
	PhysicsPrimitive * mFollowObj;

	bool mEnableFollow;
	
	//XXX Right now just returns invec, but needs to check boundaries of the world.
	void SetPosAsFarAsPossible( const glm::vec2 & inVec );
	
	void SetCenter(const glm::vec2 & cent);
};

#endif
